//
//  Comment.swift
//  FM
//
//  Created by x on 2017/9/26.
//  Copyright © 2017年 HLB. All rights reserved.
//

import UIKit

class Comment: NSObject {
    
    /// 该条品论ID
    var id:String?
    
    /// 该用户id
    var user_id:String?
    
    /// 评论内容
    var content:String?
    
    /// 评论时间
    var created:String?
    
    /// 字符串格式时间
    var created_str:String? {
        didSet {
            guard created_str != nil else {
                return
            }
            let times = created_str?.components(separatedBy: ":")
            comment_time = (times?[0])!+":"+(times?[1])!
        }
    }
    
    var zannum:Int?
    
    var replynum:Int?
    
    var role:Int?
    
    var role_id:Int?
    
    /// 该评论用户
    var user:User?
    
    var is_comment:Int?
    
    var is_host_speaker:Int?
    
    /// 保存评论时间
    var comment_time:String?
    
    
    init(dic:[String:AnyObject]) {
        super.init()
        setValuesForKeys(dic)
    }
    override func setValue(_ value: Any?, forKey key: String) {
        super.setValue(value, forKey: key)
        //拦截kvc,给用户赋值  要使用super来赋值
        if "user" == key {
            user = User(dic: value as! [String:AnyObject])
            return
        }
    }
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        //print("Radio===key=======\(key)")
    }

    override var description: String {
        let keys = ["id","user_id","content","created","created_str","user"]
        let dic = dictionaryWithValues(forKeys: keys)
        
        return "\(dic)"
    }
    
}





